package yja.gzw.app.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import yja.gzw.app.R
import yja.gzw.app.model.bean.Transactionmx

class MinxiAdapter (private val context: Context, private val list: List<Transactionmx>):RecyclerView.Adapter<RecyclerView.ViewHolder>(){
    private var view: View?=null
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        view=LayoutInflater.from(parent.context).inflate(R.layout.item_minxi,parent,false)
        return ViewHodeView(view!!)

    }

    override fun getItemCount(): Int {
      return list.size
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if(holder is ViewHodeView){

        holder.shijian.text=list[position].createtime_text
        holder.zhuangtai.text=list[position].memo
        holder.qianshu.text=list[position].money

        if(list[position].memo=="用户提现"){
            holder.qianshu.setTextColor(context.resources.getColor(R.color.lan))

        }else{

            holder.qianshu.setTextColor(context.resources.getColor(R.color.hong))
        }


        }


    }

    inner class ViewHodeView(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val zhuangtai: TextView =itemView.findViewById(R.id.zhuangtai)
        val qianshu: TextView =itemView.findViewById(R.id.qianshu)
        val shijian: TextView =itemView.findViewById(R.id.shijian)

    }

}